﻿using SqlSugar;
using System.Collections.Generic;
using System.Threading.Tasks;
using WPFNote.Models;
using WPFNote.Utilities.ReturnJson;

namespace WPFNote.Services.IDal
{
    /// <summary>
    /// 基类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <typeparam name="TS"></typeparam>
    public interface IServiceBasic<T, in TS> where T : Models.BaseEntity, new() where TS : Models.BaseEntitySch, new()
    {
        /// <summary>
        /// 写入
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<bool> InsertAsync(T t);
        /// <summary>
        /// 批量写入
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<bool> InsertAsync(T[] t);
        /// <summary>
        /// 写入并返回ID
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<int> InsertReturnIdAsync(T t);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<bool> UpdateAsync(T t);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="t"></param>
        /// <param name="ts"></param>
        /// <returns></returns>
        Task<bool> UpdateAsync(T t, TS ts);
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<bool> UpdateAsync(T[] t);
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="t"></param>
        /// <param name="ts"></param>
        /// <returns></returns>
        Task<bool> UpdateAsync(T[] t, TS ts);
        /// <summary>
        /// 单个删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> DeleteAsync(int id);
        /// <summary>
        /// 单个删除
        /// </summary> 
        /// <param name="t"></param>
        /// <param name="ts"></param>
        /// <returns></returns>
        Task<int> DeleteAsync(T t, TS ts);
        /// <summary>
        /// 多个删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        Task<bool> DeleteAsync(string[] ids);
        /// <summary>
        /// 根据ID查询单个
        /// </summary>
        /// <returns></returns>
        Task<T> SelectAsync(int id);
        /// <summary>
        /// 自定义条件单个查询
        /// </summary>
        /// <param name="ts"></param>
        /// <returns></returns>
        Task<T> SelectAsync(TS ts);
        /// <summary>
        /// 查询全部数据
        /// </summary>
        /// <returns></returns>
        Task<List<T>> SelectListAsync();
        /// <summary>
        /// 自定义条件查询列表
        /// </summary>
        /// <param name="ts"></param>
        /// <returns></returns>
        Task<List<T>> SelectListAsync(TS ts);
        /// <summary>
        /// 分页查询全部数据
        /// </summary>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        Task<List<T>> SelectListAsync(int page, int size, RefAsync<int> total);
        /// <summary>
        /// 自定义查询条件分页查询列表
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        Task<List<T>> SelectListAsync(TS ts, int page, int size, RefAsync<int> total);
    }
}